<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no"
    />
    <title>社区诉求提交</title>
    <style>
      html,
      body {
        margin: 0;
        padding: 0;
        font-family: "PingFang SC", "Helvetica Neue", Arial, "Microsoft YaHei",
          sans-serif;
        background: #f7f8fa;
        min-height: 100vh;
      }
      .container {
        max-width: 480px;
        margin: 0 auto;
        min-height: 100vh;
        background: #fff;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        box-shadow: 0 2px 12px rgba(109, 143, 255, 0.08);
      }
      .top-banner {
        position: relative;
        width: 100%;
        height: 140px;
        overflow: hidden;

      }
      .top-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
      }
      .top-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 2;
     }
      .top-title {
        color: #fff;
        font-size: 1.6rem;
        font-weight: bold;
        letter-spacing: 2px;
        text-shadow: 0 2px 8px rgba(0,0,0,0.25);
        margin-bottom: 8px;
        text-align: center;
      }
      .top-quote {
        color: #fff;
        font-size: 1.08rem;
        font-weight: 500;
        text-align: center;
        line-height: 1.3;
        text-shadow: 0 2px 8px rgba(0,0,0,0.25);
        max-width: 90%;
        word-break: break-all;
      }
      .back-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        color: #222;
        background: none;
        border: none;
        cursor: pointer;
        position: absolute;
        left: 0;
      }
      .form-card {
        background: #fff;
        border-radius: 18px;
        margin: 0 0 0 0;
        box-shadow: none;
        padding: 0 0 24px 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 60vh;
      }
      .form-list {
        padding: 18px 18px 0 18px;
      }
      .form-item {
        display: flex;
        align-items: flex-start;
        padding: 0 0 18px 0;
        font-size: 1.08rem;
        flex-direction: column;
      }
      .form-label {
        color: #222;
        font-weight: 500;
        margin-bottom: 6px;
        font-size: 15px;
      }
      .form-label .required {
        color: #ff4d4f;
        margin-right: 2px;
      }
      .form-value {
        color: #222;
        width: 100%;
        font-weight: 400;
      }
      .form-value input,
      .form-value textarea {
        width: 100%;
        border: none;
        outline: none;
        font-size: 1.08rem;
        background: #f7f8fa;
        color: #222;
        border-radius: 10px;
        padding: 12px 10px;
        margin-bottom: 0;
        box-sizing: border-box;
        margin-top: 0;
      }
      .form-value textarea {
        min-height: 56px;
        line-height: 1.6;
        margin-top: 2px;
      }
      .form-item:last-child {
        padding-bottom: 0;
      }
      .tip {
        color: #ff6b81;
        font-size: 1rem;
        padding: 0 18px;
        margin-top: 18px;
        margin-bottom: 0;
        line-height: 1.7;
      }
      .submit-btn {
        width: 90%;
        margin: 36px auto 0 auto;
        display: block;
        background: linear-gradient(90deg, #2d8cff 0%, #409eff 100%);
        color: #fff;
        font-size: 1.3rem;
        /* font-weight: bold; */
        border: none;
        border-radius: 24px;
        padding: 16px 0;
        box-shadow: 0 4px 16px rgba(45, 140, 255, 0.1);
        cursor: pointer;
        transition: background 0.2s;
      }
      .submit-btn:active {
        background: linear-gradient(90deg, #409eff 0%, #2d8cff 100%);
      }
      .photo-upload {
        width: 80px;
        height: 80px;
        background: #f7f8fa;
        border: 1.5px dashed #d9d9d9;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #bfbfbf;
        font-size: 32px;
        margin-bottom: 8px;
        margin-top: 4px;
      }
      .disabled-input {
        background: #f7f8fa !important;
        color: #bbb !important;
      }
      .form-value input::placeholder,
      .form-value textarea::placeholder {
        color: #bbb;
        font-size: 1.08rem;
      }
      .tip-bg {
        background: url('./bg1.jpg') no-repeat center top;
        background-size: cover;
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        color: #222;
        font-weight: 500;
        font-size: 1.08rem;
        padding: 32px 18px 24px 18px;
        margin-bottom: 0;
        margin-top: 0;
        position: relative;
        overflow: hidden;
        z-index: 1;
      }
      .tip-bg::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(180deg, rgba(255,255,255,0.7) 60%, rgba(255,255,255,1) 100%);
        pointer-events: none;
        z-index: 1;
      }
      .tip-bg-content {
        position: relative;
        z-index: 2;
        color: #000;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="top-banner">
        <img src="./image.png" alt="城市图" class="top-img" />
        <div class="top-content">
          <div class="top-title">群众诉求</div>
          <div class="top-quote">
            习近平总书记指出：要实施更多有温度的举措，落实更多暖民心的行动，用心用情用力解决好人民群众的急难愁盼问题。
          </div>
        </div>
      </div>
      <div class="form-card">
        <form id="appealForm" autocomplete="off" onsubmit="submitAppeal(event)">
          <div class="form-list">
            <!-- <div class="form-item">
              <span class="form-label"
                ><span class="required">*</span>照片上传</span
              >
              <div class="photo-upload">
                <span style="font-size: 32px">📷</span>
              </div>
            </div> -->

            <div class="form-item">
              <span class="form-label"
                ><span class="required">*</span>居民姓名</span
              >
              <div class="form-value">
                <input
                  type="text"
                  name="name"
                  placeholder="请输入居民姓名"
                  required
                  maxlength="10"
                />
              </div>
            </div>

            <div class="form-item">
              <span class="form-label"
                ><span class="required">*</span>电话号码</span
              >
              <div class="form-value">
                <input
                  type="text"
                  name="phone"
                  placeholder="请输入电话号码"
                  required
                  maxlength="20"
                />
              </div>
            </div>

            <div class="form-item">
              <span class="form-label"
                ><span class="required">*</span>地址</span
              >
              <div class="form-value">
                <input
                  type="text"
                  name="address"
                  placeholder="请输入地址"
                  required
                  maxlength="50"
                />
              </div>
            </div>
            <!-- <div class="form-item">
              <span class="form-label">当前时间</span>
              <div class="form-value">
                <input
                  class="disabled-input"
                  type="text"
                  id="currentTime"
                  readonly
                />
              </div>
            </div> -->
            <div class="form-item">
              <span class="form-label"><span class="required">*</span>诉求内容</span>
              <div class="form-value">
                <textarea
                  name="content"
                  placeholder="请详细描述您的诉求..."
                  required
                  maxlength="200"
                ></textarea>
              </div>
            </div>
          </div>
          <div class="tip">
            
		              诉求受理会尽快为您处理，如有紧急事宜请拨打以下电话：<br/>
			                  <span style="color: #ff6b81">工作日9:00—17:00 值班电话：028-84510896</span><br/>
					              <span style="color: #ff6b81">夜间及节假日全天值班电话：028-84528991</span><br/>
						                  <span style="color: #ff6b81">牛市口大队24小时值班电话：18919566217</span>
								            </div>
          </div>
          <button class="submit-btn" type="submit">提交</button>
        </form>
      </div>
    </div>
    <script>
      function updateCurrentTime() {
        var now = new Date();
        var y = now.getFullYear();
        var m = (now.getMonth() + 1).toString().padStart(2, "0");
        var d = now.getDate().toString().padStart(2, "0");
        var h = now.getHours().toString().padStart(2, "0");
        var min = now.getMinutes().toString().padStart(2, "0");
        var s = now.getSeconds().toString().padStart(2, "0");
        document.getElementById(
          "currentTime"
        ).value = `${y}-${m}-${d} ${h}:${min}:${s}`;
      }
      updateCurrentTime();
      setInterval(updateCurrentTime, 1000);

      function submitAppeal(event) {
        if (event) event.preventDefault();
        var form = document.getElementById("appealForm");
        if (!form.checkValidity()) {
          form.reportValidity();
          return;
        }
        const workOrder = {
          username: form.name.value.trim(),
          phone: form.phone.value.trim(),
          address: form.address.value.trim(),
          workOrderContent: form.content.value.trim(),
        };
        fetch("http://47.120.35.89:8013/dev-api/nsk/workOrdersAi/addByH5", {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            // Authorization:
            //   "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJzeXNfdXNlcjoxIiwicm5TdHIiOiJndEFOcGxIQW9Ga29GdndGRFA0ZjNXN3Q3QVFjQ2hYeiIsInVzZXJJZCI6MX0.94GERdsRREZ_4XcEGmV1LASS4-x0r1OANumEJFfoFgo",
          },
          body: JSON.stringify(workOrder),
        })
          .then((res) => res.text()) // 先用 text 看原始返回
          .then((txt) => {
            try {
              const res = JSON.parse(txt);
              if (res.code === 200) {
                alert("提交成功！我们会尽快联系您。");
                form.reset();
              } else {
                alert(res.msg || "提交失败，请稍后再试");
              }
            } catch (e) {
              alert("返回内容：" + txt);
            }
          })
          .catch(() => {
            alert("网络异常，提交失败");
          });
      }
    </script>
  </body>
</html>
